import Vue from 'vue'
import Vuex from 'vuex'
import {img_path} from "./utils/StringUtils";

Vue.use(Vuex)


const store = new Vuex.Store({
  state: {
    userinfo: {
      username: 'null',
      password: 'null',
      avatar: 'null'
    },
    sys_features: []
  },
  mutations: {
    setUserInfo (state, userInfo){
      // userInfo.avatar = img_path+userInfo.avatar
      console.debug("store setUserInfo method userinfo:"+JSON.stringify(userInfo))
      state.userinfo = userInfo
    },
    updateAvatar(state, avatar){
      console.debug("store updateAvatar method avatar:"+img_path+avatar)
      state.userinfo.avatar = img_path+avatar
    },
    setSysFeatures(state, features){
      console.debug("store setSysFeatures method features size:"+features.length)
      state.sys_features = features
    }
  },
  getters: {
    inc_inc: function (state) {
      return state.count+5
    }
  }
})

export default store
